cmake_minimum_required(VERSION 2.6)
file(GLOB PICTURES ./*.svg)
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/res")

foreach(PICTURE ${PICTURES})
    get_filename_component(PICNAME ${PICTURE} NAME)
    set(ICONNAME icon-${PICNAME})
    string(REPLACE ".svg" "" HEADERNAME ${ICONNAME})
    string(MAKE_C_IDENTIFIER ${HEADERNAME} ICONNAME)
    message(STATUS "Generating icon header ${ICONNAME}.h")
    execute_process(COMMAND "gdk-pixbuf-csource" "--raw" "--name=binary_${ICONNAME}" "${PICTURE}" OUTPUT_FILE "${CMAKE_BINARY_DIR}/res/${ICONNAME}.h")
endforeach()

message(STATUS "Generating style header yage_theme_css.h")
file(READ yage-theme.css CSSFILE)
string(REPLACE "\n" "\\n\"\n\"" CSSSTRING "${CSSFILE}")
file(WRITE "${CMAKE_BINARY_DIR}/res/yage_theme_css.h" "// Generated by CMake automatically, do not modify!\n\n#ifndef _YAGE_THEME_CSS_H\n#define _YAGE_THEME_CSS_H\n\nstatic const unsigned char binary_yage_theme_css[] = \"")
file(APPEND "${CMAKE_BINARY_DIR}/res/yage_theme_css.h" "${CSSSTRING}")
file(APPEND "${CMAKE_BINARY_DIR}/res/yage_theme_css.h" "\";\n\n#endif")
